﻿@using TaskoMask.BuildingBlocks.Contracts.Dtos.Tasks

<div class="list-group task-list-group mb-3">
    <div class="list-group-item task-list-group-header">
        <h4>
            @Model.Title
            <a @onclick="@(()=>ShowUpdateTaskModal(Model.Id))" class="text-warning float-right">
                <small class="bi bi-pencil" style="font-size:15px;">edit task</small>
            </a>
        </h4>

    </div>

    <div class="list-group-item task-list-group-item">
      <div class="">
            @Model.Description
      </div>
    </div>
</div>


@code {
    [Parameter]
    public GetTaskDto Model { get; set; }


    protected override Task OnInitializedAsync()
    {
        if (string.IsNullOrEmpty(Model.Description))
            Model.Description = "This task has not any description. you can add it by edit task link";

        return base.OnInitializedAsync();
    }

    /// <summary>
    ///
    /// </summary>
    private void ShowUpdateTaskModal(string taskId)
    {
        var parameters = new ModalParameters();
        parameters.Add(nameof(Pages.Tasks.Components.UpdateTask.Id), taskId);
        ModalService.Show<Pages.Tasks.Components.UpdateTask>("Update Task", parameters, new ModalOptions { Class = "blazored-modal w-75 w-md-50 bg-light-gray" });
    }
}
